package com.ssm.lzh.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ssm.hj.page.Page;
import com.ssm.lzh.serachId.SerachId;
import com.ssm.lzh.service.PackageService;
import com.ssm.lzh.vo.projectvo;
import com.ssm.mapper.PackageMapper;
import com.ssm.pojo.Package;
import com.ssm.pojo.Project;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class PackageServiceImpl implements PackageService {

    @Resource
    private PackageMapper packageMapper;


    //分页查询
    @Override
    public PageInfo<Package> queryAllPackage(Page<Package> page) {
        PageHelper.startPage(page.getPageNum(),page.getPageSize());
        return new PageInfo<Package>(this.packageMapper.queryAllPackage(page.getSearchObj())) ;
    }

    //添加套餐信息和套餐里的检查项目
    @Override
    public int addPackage(projectvo<Package> projectvo) {
        this.packageMapper.addPackage(projectvo.getObj());
        this.packageMapper.addpackage_pro(projectvo);
        return 0;
    }




    @Override
    public int updatePackage(projectvo<Package> projectvo) {
        this.packageMapper.updatePackage(projectvo.getObj());
        this.packageMapper.deletePack_pro(projectvo.getObj().getTid());
        this.packageMapper.addpackage_pro(projectvo);
        return 0;
    }

    @Override
    public List<Package> queryTzAll() {
        return this.packageMapper.queryTzAll();
    }

    @Override
    public List<Project> queryProByTcId(int tid) {
        return this.packageMapper.queryProByTcId(tid);
    }
}
